package com.lzh.healthCode.business.task;

import com.lzh.healthCode.business.controller.TestController;
import com.lzh.healthCode.business.controller.TimingController;
import com.lzh.healthCode.utils.UpdAreaEnum;
import com.lzh.healthCode.utils.UpdTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 测试定时任务
 *
 * @author suYanLong
 * @date 2022年07月09日 16:00
 */
@Slf4j
@Component
public class TestTask {

    @Resource
    TimingController timingController;

    @Resource
    TestController testController;
//    @Resource
//    JgInfoService jgInfoService;

//    @Scheduled(cron = "0 * * * * ?")
//    public void task() {
//        log.info("定时打印任务");
//    }

//    @Scheduled(cron = "0 * * * * ?")
//    public void task1()
//        {
//            jgInfoService.checkResultReport();
//    }

    @Scheduled(cron = "0 15 * * * ?")
    public void sampleReport() {
        try {
            testController.sampleReport();
        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }

    }

    @Scheduled(cron = "0 20 * * * ?")
    public void transportReport() {
        try {
            testController.transportReport();
        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }

    }

    @Scheduled(cron = "0 25 * * * ?")
    public void checkResultReport() {
        try {
            testController.checkResultReport();
        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }

    }

    @Scheduled(cron = "0 0/20 * * * ?")
//    @Scheduled(cron = "0 0/1 * * * ?")
    public void sampleReport1() {
        try {
            timingController.sampleReport(UpdAreaEnum.UPD_AREA_TYPE_1, UpdTypeEnum.UPD_TYPE_2);
//            timingController.sampleReport(UpdAreaEnum.UPD_AREA_TYPE_2, UpdTypeEnum.UPD_TYPE_2);
        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }
    }

    @Scheduled(cron = "0 0/30 * * * ?")
    public void transportReport1() {
        try {
            timingController.transportReport(UpdAreaEnum.UPD_AREA_TYPE_1, UpdTypeEnum.UPD_TYPE_2);
//            timingController.transportReport(UpdAreaEnum.UPD_AREA_TYPE_2, UpdTypeEnum.UPD_TYPE_2);
        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }

    }

    @Scheduled(cron = "0 0/40 * * * ?")
    public void checkResultReport1() {
        try {
            timingController.checkResultReport1(UpdAreaEnum.UPD_AREA_TYPE_1, UpdTypeEnum.UPD_TYPE_2);
//            timingController.checkResultReport1(UpdAreaEnum.UPD_AREA_TYPE_2, UpdTypeEnum.UPD_TYPE_2);

        } catch (Exception e) {
            log.error("异常信息：{}", e);
            e.printStackTrace();
        }

    }

}
